/*
 * Copyright (C) 2023 xuexiangjys(xuexiangjys@163.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.xuexiang.templateproject.adapter;

import android.app.Dialog;
import android.content.Context;
import android.view.Display;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

import com.xuexiang.templateproject.bean.PageCourse;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagFlowLayout;
//import d.m.b.l.b.c;
import java.util.List;
import com.xuexiang.templateproject.R;
//import kotlin.Lazy;
//import kotlin.LazyKt__LazyJVMKt;
//import kotlin.Metadata;
//import kotlin.jvm.internal.Intrinsics;
//import org.jetbrains.anko.Sdk27ServicesKt;
import org.jetbrains.annotations.NotNull;
//
///* compiled from: SubjectDialog.kt */
//@Metadata(d1 = {"\u00002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\r\n\u0002\u0010\u0002\n\u0002\b\u0003\u0018\u00002\u00020\u0001:\u0001\u001bB#\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\f\u0010\u0004\u001a\b\u0012\u0004\u0012\u00020\u00060\u0005\u0012\u0006\u0010\u0007\u001a\u00020\b¢\u0006\u0002\u0010\tJ\b\u0010\u0018\u001a\u00020\u0019H\u0002J\b\u0010\u001a\u001a\u00020\u0019H\u0002R\u001b\u0010\n\u001a\u00020\u000b8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u000e\u0010\u000f\u001a\u0004\b\f\u0010\rR\u001a\u0010\u0007\u001a\u00020\bX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0010\u0010\u0011\"\u0004\b\u0012\u0010\u0013R \u0010\u0004\u001a\b\u0012\u0004\u0012\u00020\u00060\u0005X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0014\u0010\u0015\"\u0004\b\u0016\u0010\u0017¨\u0006\u001c"}, d2 = {"Lcom/jcds/learneasy/dialog/SubjectDialog;", "Landroid/app/Dialog;", d.R, "Landroid/content/Context;", Constants.SP.SUBJECTS, "", "Lcom/jcds/learneasy/entity/PageCourse;", "itemOnClickListener", "Lcom/jcds/learneasy/dialog/SubjectDialog$ItemClickListener;", "(Landroid/content/Context;Ljava/util/List;Lcom/jcds/learneasy/dialog/SubjectDialog$ItemClickListener;)V", "adapter", "Lcom/jcds/learneasy/ui/adapter/MyTagAdapter;", "getAdapter", "()Lcom/jcds/learneasy/ui/adapter/MyTagAdapter;", "adapter$delegate", "Lkotlin/Lazy;", "getItemOnClickListener", "()Lcom/jcds/learneasy/dialog/SubjectDialog$ItemClickListener;", "setItemOnClickListener", "(Lcom/jcds/learneasy/dialog/SubjectDialog$ItemClickListener;)V", "getSubjects", "()Ljava/util/List;", "setSubjects", "(Ljava/util/List;)V", "initData", "", "initEvent", "ItemClickListener", "app_huaweiRelease"}, k = 1, mv = {1, 7, 1}, xi = 48)
///* loaded from: classes2.dex */
public final class SubjectDialog extends Dialog {
    @NotNull

    /* renamed from: a  reason: collision with root package name */
    public List<PageCourse> f3777a;
    @NotNull

    /* renamed from: b  reason: collision with root package name */
    public a f3778b;
//    @NotNull

    /* renamed from: c  reason: collision with root package name */
//    public final Lazy f3779c;
//
//    /* compiled from: SubjectDialog.kt */
//    @Metadata(d1 = {"\u0000\u0016\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\bf\u0018\u00002\u00020\u0001J\u0010\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u0005H&¨\u0006\u0006"}, d2 = {"Lcom/jcds/learneasy/dialog/SubjectDialog$ItemClickListener;", "", "onItemClick", "", "pageCourse", "Lcom/jcds/learneasy/entity/PageCourse;", "app_huaweiRelease"}, k = 1, mv = {1, 7, 1}, xi = 48)
//    /* loaded from: classes2.dex */
    public interface a {
        void a(@NotNull PageCourse pageCourse);
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public SubjectDialog(@NotNull Context context, @NotNull List<PageCourse> subjects, @NotNull a itemOnClickListener) {
        super(context, R.style.CustomDialog);
//        Intrinsics.checkNotNullParameter(context, "context");
//        Intrinsics.checkNotNullParameter(subjects, "subjects");
//        Intrinsics.checkNotNullParameter(itemOnClickListener, "itemOnClickListener");
        this.f3777a = subjects;
        this.f3778b = itemOnClickListener;
//        this.f3779c = LazyKt__LazyJVMKt.lazy(new SubjectDialog$adapter$2(this, context));
        setContentView(R.layout.layout_dialog_subject);
        setCancelable(false);
        setCanceledOnTouchOutside(false);
        Window window = getWindow();
        WindowManager.LayoutParams attributes = window != null ? window.getAttributes() : null;
        if (attributes != null) {
            attributes.gravity = 80;
        }
        Display defaultDisplay = getOwnerActivity().getWindowManager().getDefaultDisplay();//Sdk2
//        Display defaultDisplay = Sdk27ServicesKt.getWindowManager(context).getDefaultDisplay();
        if (attributes != null) {
            attributes.width = defaultDisplay.getWidth();
        }
        Window window2 = getWindow();
        if (window2 != null) {
            window2.setAttributes(attributes);
        }
        c();
        d();
    }

    public static final void e(SubjectDialog this$0, View view) {
//        Intrinsics.checkNotNullParameter(this$0, "this$0");
        if (this$0.isShowing()) {
            this$0.dismiss();
        }
    }

    public static final boolean f(SubjectDialog this$0, View view, int i2, FlowLayout flowLayout) {
//        Intrinsics.checkNotNullParameter(this$0, "this$0");
        this$0.f3778b.a(this$0.f3777a.get(i2));
        this$0.dismiss();
        return true;
    }
    private MyTagAdapter mMyTagAdapter;
    public final MyTagAdapter getMyTagAdapter() {
        if(mMyTagAdapter==null){
            mMyTagAdapter = new MyTagAdapter(SubjectDialog.this.b(),getContext(), R.layout.item_text_view, 70.0f, 40.0f, R.drawable.bg_white_corner);
        }
        return mMyTagAdapter;
    }

    @NotNull
    public final List<PageCourse> b() {
        return this.f3777a;
    }

    public final void c() {
        ((TagFlowLayout) findViewById(R.id.tagFlowLayout)).setAdapter(getMyTagAdapter());
    }

    public final void d() {
        ((ImageView) findViewById(R.id.ivClose)).setOnClickListener(new View.OnClickListener() { // from class: d.m.b.g.g0
            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                SubjectDialog.e(SubjectDialog.this, view);
            }
        });
        ((TagFlowLayout) findViewById(R.id.tagFlowLayout)).setOnTagClickListener(new TagFlowLayout.OnTagClickListener() {

            @Override // com.zhy.view.flowlayout.TagFlowLayout.c
            public final boolean onTagClick(View view, int i2, FlowLayout flowLayout) {
                boolean f2;
                f2 = SubjectDialog.f(SubjectDialog.this, view, i2, flowLayout);
                return f2;
            }
        });
    }
}